/*User program on Nachos
  For project 4
*/

/*Author: Yuzhe Wu 4/14*/


#include "syscall.h"
#include "user.h"
#include "create.h"
#include "doctorOffice.h"

void main() {

	int nurseNum;
	int i = 0;
	int localExamRoomNum = -1;
	myMV examRoomNum = -1;
	myMV examState = -1;
	
	Printf("Please enter the number of Nurse(1 to 5)\n");
	nurseNum = InputInt();
	while ( !(nurseNum>=1&&nurseNum<=5)){
		Printf("You must input an Integer(1 to 5)\n");
		Printf("Please reenter the number of Nurses(1 to 5)\n");
		nurseNum = InputInt();			
	}
	
	Printf("Please enter the number of Examination Rooms(1 to 5)\n");
	localExamRoomNum = InputInt();
	while ( !(localExamRoomNum>=1&&localExamRoomNum<=5)){ 
		Printf("You must input an Integer(1 to 5)\n");
		Printf("Please reenter the number of Examination Rooms(1 to 5)\n");
		localExamRoomNum = InputInt();			
	}	
	

	examRoomNum = rpcCreateMV("ERNUM",sizeof("ERNUM"),1,0);
	examState = rpcCreateMV("ESt",sizeof("ESt"),MAXEXAMROOMNUM,FREE);
	
	rpcSetValueMV(examRoomNum,0,localExamRoomNum);
	for (i=localExamRoomNum;i<MAXEXAMROOMNUM;i++) {
		rpcSetValueMV(examState,i,BUSY);
	}	
	
	for(i=0; i < nurseNum; i++){
		Exec("../test/nurse",sizeof("../test/nurse"));
		delay();
	}
	Exit(0);

}